﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DingY.DB;

namespace DotNet.WinUI.Admin
{
    public partial class FrmUsersList : Form
    {
        public FrmUsersList()
        {
            InitializeComponent();
        }

        private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            switch (e.ClickedItem.Text)
            {
                case "新增":
                    (new FrmUsersEdit("0")).ShowDialog();
                    break;
                case "编辑":
                    string _SerialID = dgUsers.SelectedCells[0].Value.ToString();
                    if (string.IsNullOrEmpty(_SerialID))
                    {
                        MessageBox.Show("没有选择有效的用户信息！");
                        return;
                    }
                    (new FrmUsersEdit(_SerialID)).ShowDialog();
                    break;
                case "删除":
                    break;
                case "关闭":
                    Close();
                    break;
            }
            LoadUsers();
        }


        private void LoadUsers()
        {
            string _sql = @"SELECT LoginID AS 登录代码, Name AS 姓名, Depict AS 描述
                FROM Users ";

            SqlDB objSqlDB = new SqlDB();
            dgUsers.DataSource = objSqlDB.ExecuteDataView(_sql);
        }

        private void FrmUsersList_Load(object sender, EventArgs e)
        {
            LoadUsers();
        }
    }
}
